home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Net / Utilities / Seer family 2.0 / docs / sr_doc < prev    next >
Encoding:
Text File  |  1987-08-29  |  6.1 KB  |  126 lines  |  [TEXT/KAHL]

  1.  
  2. Here is how the SCC hardware and interrupt routines receive AppleTalk
  3. packets.  See figure 4 in "Inside Macintosh", pages III-26, to see how 
  4. the signals from AppleTalk get to SCC (they come in on RXD- and RXD+ from 
  5. the little box hanging out back).  
  6.  
  7. The SCC (Zilog 8530) serial communications controller receives the bits and 
  8. assembles them into bytes. If you are going to be programming the SCC, you
  9. will need to get a copy of the Z8530 section of a Zilog data book, which will 
  10. explain (to some extent) what the zillions of registers are for.
  11.  
  12. Macintosh to SCC I/O Interface:
  13.   
  14.   The SCC has two registers presented to the bus for each channel (A and B).
  15.   Each register can be read and written to.  For writing to the SCC
  16.   use the address in system global SCCWr + (aData(6), bData(4), aCtl(2),
  17.   bCtl(0)) depending on which register you want.  For reading to the SCC, use
  18.   SCCRd, which is accessed the same way. 
  19.   
  20.   To read or write to the SCC, you generally do a write to the control port
  21.   to tell it which internal register you want. Then you do a read or a write 
  22.   to the control port again to get/send the data you want  Be sure to have at 
  23.   least one instruction delay between accesses (one NOP instruction is fine) 
  24.   to meet the SCC timing requirments.
  25.  
  26. Macintosh to SCC Interrupts:
  27.  
  28.   There are two channels, SCC B and SCC A, which are basically independent in 
  29.   the operation and seperation of their registers and wiring.  The only 
  30.   exceptions are RR2 and RR3 (read registers 2 and 3). RR3 is the interrupt
  31.   pending status register and can only be read from channel B.  RR2 is
  32.   the interrupt vector register (SCC interrupts do not vector according to 
  33.   this hardware vector, they vector according to 68000 interrupt level only - 
  34.   more on this later).  If you read RR2 from the B side it always
  35.   returns the interrupt vector that the SCC was initilized with (which should
  36.   always be set to zero or the ROM interrupt handler will be confused). 
  37.   However, when you read from side A the interrupt vector is modified by the
  38.   8 different possible pending interrupts (according to the highest SCC
  39.   priority).
  40.  
  41.  
  42.   When the SCC requests an interrupt from the 68K, the 68K pushes the SR 
  43.   (status /CCR register) and PC onto the stack.  Since the SCC is on level
  44.   2 (see "Inside Macintosh", pages III-197 fig 4) the 68K loads the contents 
  45.   of the long word at $68 into the program counter.  On my Macintosh Plus, 
  46.   $68 points to $401A84, which does the following:
  47.           save D0-D3/A0-A3;        /* preserve the users registers */
  48.           A0 := SCCRd;            /* setup SCC read/write addresses */
  49.           A1 := SCCWr;
  50.           D0 := *SCCRd & 0xe0;    /* see who is interrupting within the SCC */
  51.         if(D0>=8) {                /* channel A? */
  52.           A0 +=2;                /* yes, change SCC addresses to point to */
  53.           A1 +=2;                /* SCC A registers instead of B registers */
  54.           }                        /* else A0/A1 point to B */
  55.         A2 := Lvl2DT[D0];        /* select service routine */
  56.         JSR (A2)                /* call the service routine */
  57.         restore D0-D3/A0-A3;    /* put the users register back */
  58.         RTE                        /* return from interrupt */
  59.         
  60.  Put your own transmit buffer empty, receive special condition, and
  61.  receive character interrupt handlers into Lvl2DT. Do *NOT* change
  62.  the external status entry in Lvl2DT because the mouse vertical and
  63.  horizotal position sensors are connected to a general purpose input to the
  64.  SCC.  If the mouse moves vertically you get SCC B external interrupts.  So
  65.  do not change the external interrupt in Lvl2DT, as it checks to see if the
  66.  interrupt is due to the mouse or communications, and vectors thru ExtStsDT.
  67.  
  68.  Again on my Macintosh Plus, Lvl2DT+4 (SCC B external) points to this routine 
  69.  in  the ROM:
  70.  
  71.  channel_B_external_interrupt:
  72.    D0 :=SCCRd+bCtl;        /* get SCC status */
  73.    A2 :=ExtStsDt;        /* point to the B side of ExtStsDt */
  74.    A3 := &SCCBSts;        /* point to SCC status byte in low memory */
  75.    goto common_external_interrupt
  76.    
  77.  channel_A_external_interrupt:
  78.    D0 :=SCCRd+aCtl;        /* get SCC status */
  79.    A2 :=ExtStsDt+8;        /* point to the A side of ExtStsDt */
  80.    A3 := &SCCASts;        /* point to SCC status byte in low memory */
  81.  
  82.  common_external_interrupt:
  83.    /* here we set D1 to be those status bits in RR0 (abort, tx undeflow,
  84.       CTS (clear to send), sync/hunt, DCD (mouse), Tx empty, zero in baud
  85.       generator, Rx available, anded with those channels that are enabled.
  86.  
  87.       In other words, D1 is those RR0 conditions that are different that
  88.       we are interested in.
  89.    */
  90.    D1 := ( *SCCxSts Xor RR0) && RR15;
  91.    /* save current state so next interrupt can know what is different */
  92.    *SCCxSts := D0;
  93.    /* is the *ONLY* new status change due to the mouse? */
  94.    if( D1 = 8)            /* check DCD SCC input */
  95.      A2 +=2;            /* yes,just the mouse, select mouse interrupt routine */
  96.    /* *************** very important ************** */
  97.    /* tell the SCC that the current interrupt had been serviced, (end IUS
  98.       interrupt under service.  NOTE: for all the other routines you
  99.       might write interrupt handlers for (data interrupt, trasmit, special)
  100.       they must do a IUS to the SCC.  For the external interrupt, the
  101.       user routine does not, as it is done right here.
  102.    */
  103.    WW0 := $10;        /* end interrupt under service */
  104.    /* go to user external service routine.
  105.       registers:
  106.         D0 - SCC status
  107.         D1 - SCC status that is different since the last interrupt
  108.         D2 - trash
  109.         D3 - trash
  110.         A0 - SCC read address
  111.         A1 - SCC write address
  112.         A2 - trash
  113.         A3 - trash
  114.         You must preserve all the other regs.  D0-D3/A0-A3 may be trashed.
  115.         N.B.  SCC communication conditions have priority over mouse, so if
  116.         there is a communications status change at the same time the mouse moves
  117.         then this JMP (A2) only calls the communication routine.  Some 
  118.         communication routines have been seen to look at D1 and notice that 
  119.         there is a mouse interrupt also and jump to mouse routine when done 
  120.         servicing the communication interrupt.  This is fine, but in that 
  121.         case preserve A0,A1, D0,D1 as the mouse routine needs them.
  122.     */
  123.    JMP (A2)
  124.    
  125. *****************************************************************************
  126.